package com.remote.common.command.handler;

import com.remote.common.RemoteFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Arrays;

/**
 * 命令处理器
 *
 * @param <T>
 */
public abstract class BaseCommandHandler<T> implements ICommandHandler<T> {

    private static final Logger LOGGER = LoggerFactory.getLogger(BaseCommandHandler.class);
    private RemoteFactory remoteFactory;

    public BaseCommandHandler(RemoteFactory remoteFactory) {
        this.remoteFactory = remoteFactory;
    }

    public void error(Object object, String message) {
        LOGGER.error("{}:{}", object.getClass().getCanonicalName(), message);
    }

    public void debug(Object object, String... message) {
        LOGGER.debug("{}:{}", object, Arrays.toString(message));
    }

    public void info(Object object, String... message) {
        LOGGER.info("{}:{}", object, Arrays.toString(message));
    }

    public void warn(Object object, String message) {
        LOGGER.warn("{}:{}", object, message);
    }

    public RemoteFactory getRemoteFactory() {
        return remoteFactory;
    }
}
